var TableEditable = function() {
	return {
		init : function() {
			var tableId = "log_table";
			util.initCheckBox(tableId);
			function queryData(sSource, aoData, fnCallback) {
				aoData.push({
					"name" : "logContent",
					"value" : $("#logContent").val().trim()
				});
				$.ajax({
					"type" : "get",
					"contentType" : "application/json",
					"url" : sSource,
					"dataType" : "json",
					"data" : {
						"aoData" : JSON.stringify(aoData)
					},
					"success" : function(resp) {
						fnCallback(resp);
					}
				});
			};

			var t = $('#log_table').DataTable({
				"processing" : true,
				"serverSide" : true,
				"autoWidth": false,
				"sAjaxSource" : "main/syslog/getLogs.mvc",
				"fnServerData" : queryData,
				"pageLength" : 10,
				"sDom" : "<'row-fluid'r>t<'row-fluid'<'span6'i><'span6'p>>",
				"oLanguage" :util.getDToLanguage(),
				"columns" : [ {
					"data" : "pkId",
					"render" : function(data, type, full, meta) {
						 return '<div class="checker" onclick="util.selectCheckBox(\'' + tableId + '\', this)"><span><input type="checkbox" class="checkboxes"/></span></div>';
					},
					"bSortable" : false
				},
				{
					"data" : "createDate",
					"bSortable" : false,
					"defaultContent" : "",
					"render" : function(data, full, type, meta){
						if(data){
							return util.getDateStr(data);
						}
					}
					
				}, 
				{
					"data" : "username",
					"bSortable" : false,
					"defaultContent" : ""
					
				}, 
				{
					"data" : "remoteIp",
					"bSortable" : false,
					"defaultContent" : ""
				}, 
				{ 
					"data" : "modual",
					"bSortable" : false,
					"defaultContent" : ""
				}, 
				{ 
					"data" : "logConten",
					"bSortable" : false,
					"defaultContent" : ""
				}
				],
				"fnDrawCallback" : function(oSetting) {
					util.clearSelected(tableId);
				},
				"columnDefs": [
				               { "width": "30px", "targets": 1 }
				              ]
				
			});
			
			//查询
			$("#btn_query").click(function(e) {
				var table = $('#log_table').DataTable();
				table.draw(true);
			});
			$("#btn_reset").click(function(e) {
				$("#logContent").val("");
			});
			
			
			//导出
			$("#sys_log_download").click(function(e){
				util.ajaxDownload("main/syslog/exportLog.mvc");
			});
			
			
			$(function(){
				$('.search-body input').bind('keyup', function(event) {
					if (event.keyCode == "13") {
						//回车执行查询
						$('.search-button #btn_query').click();
					}
				});
			});
		}
	};
}();





